package reflect.reflect_Feild;

import reflect.reflect_class.Student;

import java.lang.reflect.Constructor;
import java.lang.reflect.Field;

public class FieldTest {
    public static void main(String[] args) throws Exception {
        Class<?> clazz = Class.forName("reflect.reflect_class.Student");
        Field[] fields = clazz.getDeclaredFields();
        Constructor<?> constructor = clazz.getDeclaredConstructor(String.class, int.class);
        constructor.setAccessible(true);
        Student stu = (Student)constructor.newInstance("张三", 23);
        Field name = clazz.getDeclaredField("name");
        name.setAccessible(true);
        System.out.println(name.get(stu));
    }
}
